<?= $this->extend('admin\_layouts\main_iframe') ?>

<?= $this->section('content') ?>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
    	<div class="layui-card">
              <div class="layui-card-header">设置我的资料</div>
              <div class="layui-card-body" pad15>
                <div class="layui-form" lay-filter="">
                  <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-inline">
                      <input type="text" name="username" value="<?php echo esc($data['username']);?>" readonly class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">不可修改，用于后台登入名</div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">真实姓名</label>
                    <div class="layui-input-inline">
                      <input type="text" name="realname" value="<?php echo esc($data['realname']);?>" lay-verify="required" autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                      <input type="radio" name="status" value="<?php echo COMMON_STATUS_ON;?>" title="<?php echo lang('common.status.'.COMMON_STATUS_ON);?>"<?php if($data['status']==COMMON_STATUS_ON){echo ' checked';}?>>
                      <input type="radio" name="status" value="<?php echo COMMON_STATUS_OFF;?>" title="<?php echo lang('common.status.'.COMMON_STATUS_OFF)?>"<?php if($data['status']==COMMON_STATUS_OFF){echo ' checked';}?>>
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-inline">
                      <input type="text" name="mobile" value="<?php echo esc($data['mobile']);?>" lay-verify="required|phone" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  <!-- <div class="layui-form-item">
                    <label class="layui-form-label">头像</label>
                    <div class="layui-input-inline">
                      <input name="avatar" lay-verify="required" id="LAY_avatarSrc" placeholder="图片地址" value="http://cdn.layui.com/avatar/168.jpg" class="layui-input">
                    </div>
                    <div class="layui-input-inline layui-btn-container" style="width: auto;">
                      <button type="button" class="layui-btn layui-btn-primary" id="LAY_avatarUpload">
                        <i class="layui-icon">&#xe67c;</i>上传图片
                      </button>
                      <button class="layui-btn layui-btn-primary" layadmin-event="avartatPreview">查看图片</button >
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">邮箱</label>
                    <div class="layui-input-inline">
                      <input type="text" name="email" value="" lay-verify="email" autocomplete="off" class="layui-input">
                    </div>
                  </div> -->
                  <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                      <textarea name="desc" placeholder="请输入内容" class="layui-textarea"><?php echo esc($data['desc']);?></textarea>
                      <?=csrf_field()?>
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <div class="layui-input-block">
                      <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                      <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                    </div>
                  </div>
                </div>
			</div>
		</div>
    </div>
</div>
</div>
<?= $this->endSection() ?>

<?= $this->section('script') ?>
<script>
layui.use(['form','layer'], function(){
    var form = layui.form
        ,layer = layui.layer
        ,$ = layui.jquery;

    form.on('submit(setmyinfo)', function(data){
    	//监听提交
        $.ajax({
            url : '/admin/info',
            type : 'post',
            dataType : 'json',
            data : data.field,
            success : function(res){
                if(res.code==0){
                	layer.open({
                 		content: res.msg,
                 	  	btn: ['确定'],
              	  	  	yes: function(index, layero){
                  	  		//确定按钮回调
                  	  	  	window.location.reload();
                        	return false;
                  	  	}
                 	});
                }else{
                    layer.open({
                        content: res.msg
                    });
                }
            }
        });
        return false;	
    });
});
</script>
<?= $this->endSection() ?>